﻿using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class AudioManager : MonoBehaviour {
    public static AudioManager instance;
    public bool errorAudio = true;
    //public AudioClip bgAudio;
    //public AudioClip startAudio;
    public AudioClip[] Audio;  /* 0 表示正确 1 表示错误 2 表示获取金币*/
    private AudioClip currentAudio;
	// Use this for initialization
	void Start () {
        instance = this;
  

    }
	
	// Update is called once per frame
	void Update () {
	
	}
    public void TrueOnclick()
    {
        this.GetComponent<AudioSource>().clip = Audio[0];
        this.GetComponent<AudioSource>().Play();      
    }
    public void FalseOnclick()
    {
        if( !errorAudio )
            return;
        this.GetComponent<AudioSource>().clip = Audio[1];
        //if( this.GetComponent<AudioSource>().isPlaying == true )
        //{
        //    return;
        //}
        this.GetComponent<AudioSource>().Play();
        errorAudio = false;
    }
    public void AddCoinOnclick()
    {
        this.GetComponent<AudioSource>().clip = Audio[2];
        this.GetComponent<AudioSource>().Play();
    }
}
